﻿<?php
ini_set('date.timezone','Asia/Shanghai');
include 'simple_html_dom.php';
include 'config_catchanzhi.php';
include 'function_catchanzhi.php';

define('APPS_NUM',2405);
define('GAMES_NUM',977);

define('DBPAS',"coolchuan2012");
//define('DBPAS',"123456");
define('LOGPATHHEADER','/var/www/catchjiankongdata/');
//define('LOGPATHHEADER','');

$link = mysql_connect("localhost","root",DBPAS); 
//$link = mysql_connect("localhost","root","coolchuan2012"); 
mysql_select_db("catchappdataall", $link);
mysql_query('SET NAMES UTF8');


define('ONCECATCHCOUNT',15);
define('ONCECOMMENTCATCHCOUNT',50);

define('WEBURLHEADER','http://www.anzhi.com/soft_');
define('WAPURLHEADER','http://m.anzhi.com');

define('WEBURLHEADERANZHI','http://www.anzhi.com/soft_');
define('WAPURLHEADERANZHI','http://m.anzhi.com/info_');




//$apps_url_page_header = "http://openbox.mobilem.360.cn/AppStore/getRecomendAppsBytype?type=1&os=17&model=HTC+Sensation&cpu=pyramid&&screen_size=960x540&startCount=21&start=0&count=".ONCECATCHCOUNT;
//$apps_url_app_all_list = "http://openboxcdn.mobilem.360.cn/AppStore/getTopapplist?type=1&os=17&model=HTC+Sensation&cpu=pyramid&&screen_size=960x540&order=down&start=0&count=".ONCECATCHCOUNT;
define('LOGFORSUCCESS',0);


getinfoandrank();

//getcomment();


function getinfoandrank()
{
	//获取已存在app基础数据
	
	//应用分类
	$apptype_arr = getapptypelist();
	
	foreach ($apptype_arr as $apptype)
	{
		if(($apptype['id']>=16) && ($apptype['id']<=17))
		{
			//每一类的url
			$apps_url_app_type_list = $apptype['url'];
			decodeurlandgetdata($apptype['id'],"soft",$apps_url_app_type_list);
		}
	}
	//应用总榜
//	decodeurlandgetdata(101,"soft","http://m.anzhi.com/recommend_1_");
	catchother();
/*	
	//游戏分类
	$gametype_arr = getgametypelist();
	foreach ($gametype_arr as $gametype)
	{
		//每一类的url
		$apps_url_game_type_list = $gametype['url'].TYPEURLFOOTER;
		decodeurlandgetdata($gametype['id'],"game",$apps_url_game_type_list);
	}
	//游戏总榜
	decodeurlandgetdata(102,"game","http://m.anzhi.com/recommend_2_");
*/
}




function get_exit_appinfo_fromdb_forcatch()
{
	$link = mysql_connect("localhost","root",DBPAS); 
	$createtime = strtotime(date("Y-m-d H:i:s"));

	$sql = 'select id, app_id, packageName,title,apptype,appbigtype from jk_apps_info_anzhi where apptype>=16 and apptype<=17  and IsDeleted=0 '; 
	$rs = mysql_query($sql, $link);
	
	$app_exit_info = array();
  	while($row=mysql_fetch_array($rs))        
  	{
  		$app_exit_info_temp = array();
  		$app_exit_info_temp['id'] = $row['id'];
  		$app_exit_info_temp['app_id'] = $row['app_id'];
	  	$app_exit_info_temp['AppPackageName'] = $row['packageName'];
	  	$app_exit_info_temp['AppName'] = $row['title'];
	  	$app_exit_info_temp['apptype'] = $row['apptype'];
	  	$app_exit_info_temp['appbigtype'] = $row['appbigtype'];
	  	$app_exit_info[] = $app_exit_info_temp;
  	}
	return $app_exit_info;
}


?>